/*
 * server_session.h
 *
 *  Created on: Dec 26, 2013
 *      Author: killerg
 */

#ifndef SERVER_SESSION_H_
#define SERVER_SESSION_H_

#include "share/session_mgr.h"
#include "share/sb_msg.pb.h"

struct server_session_t {
    tran_s* _trans;
    int64_t _sessid;
    double _idle_timer;

    server_session_t(int64_t sessid_, tran_s* trans) {
        _trans = trans;
        serverid = -1;
        _sessid = sessid_;
        _idle_timer = 20.0f;
    }


    void update();

    void on_connect();
    void on_disconnect();

    bool send_msg(sb::BMsg* msg);

    int32_t serverid;
};

struct serversess_mgr_t : public svr_session_t<server_session_t, sb::SMsg, sb::SMsgID_ARRAYSIZE, sb::BMsg, sb::BMsgID_ARRAYSIZE> {
    typedef svr_session_t<server_session_t, sb::SMsg, sb::SMsgID_ARRAYSIZE, sb::BMsg, sb::BMsgID_ARRAYSIZE> base;
    bool init();
};


#endif /* SERVER_SESSION_H_ */
